package com.regedit.aplicacion.utils;

import org.json.JSONObject;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;

import com.regedit.aplicacion.controllers.CarroController;

public class MiHilo extends AsyncTask<String, String, JSONObject> {

	private Context mContext;
	private ProgressDialog progressDialog;

	public MiHilo(Context context) {
		mContext = context;
	}

	@Override
	protected void onPreExecute() {
		progressDialog = ProgressDialog.show(mContext, "", "Cargando...");
		super.onPreExecute();
	}

	@Override
	protected JSONObject doInBackground(String... params) {
		CarroController cController = new CarroController(mContext);
		JSONObject json = cController.getCarros();
		try {
			Thread.sleep(2000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return json;
	}

	@Override
	protected void onPostExecute(JSONObject result) {
		progressDialog.dismiss();
		super.onPostExecute(result);
	}

}
